package network;

import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Build;

import java.util.ArrayList;

public class TaskExecute {
    
    public static final int SDK_API_LEVEL = 14;
    
    public static void executeListString(AsyncTask<Void, Void, ArrayList<String>> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.THREAD_POOL_EXECUTOR, (Void[]) null);
        }
    }
    
    public static void executeBitmap(AsyncTask<Void, Void, Bitmap> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.THREAD_POOL_EXECUTOR, (Void[]) null);
        }
    }
    
    public static void executeVersion(AsyncTask<Void, Integer, Void> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.THREAD_POOL_EXECUTOR, (Void[]) null);
        }
    }
    
    public static void executeVoid(AsyncTask<Void, Void, Void> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.THREAD_POOL_EXECUTOR, (Void[]) null);
        }
    }
    
    public static void executeBoolean(AsyncTask<Void, Void, Boolean> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.TASK_POOL_EXECUTOR, (Void[]) null);
        }
    }
    
    public static void executeString(AsyncTask<Void, Void, String> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.THREAD_POOL_EXECUTOR, (Void[]) null);
        }
    }
    
    public static void executeObject(AsyncTask<Void, Void, Object> task) {
        
        if (Build.VERSION.SDK_INT < SDK_API_LEVEL) {
            task.execute();
        } else {
            task.executeOnExecutor(AsyncTaskSetting.TASK_POOL_EXECUTOR, (Void[]) null);
        }
    }
}
